import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2023-03-29
 * Time: 9:33
 */
public class test08 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String str1 = null;
        String str2 = null;
        while ((str1 = reader.readLine()) != null){
            str2 = reader.readLine();
            System.out.println(findSurLen(str1,str2));
        }

    }

    private static int findSurLen(String str1, String str2) {
          char[] a1 = str1.toCharArray();
          char[] a2 = str2.toCharArray();
          int SurLen = 0;
          int[][] len = new int[str1.length()+1][str2.length()+1];
        for (int i = 1; i <= str1.length() ; i++) {
            for (int j = 1; j <= str2.length() ; j++) {
                if(a1[i - 1] == a2[j - 1]) {
                    len[i][j] = len[i - 1][j - 1] + 1;

                }
                if(SurLen < len[i][j]){
                    SurLen = len[i][j];
                }
            }

        }
        return SurLen;
    }
}
